import os
import sys

from core.rest_client import RestClient
from common.read_data import data

BASE_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(BASE_PATH)
data_file_path = os.path.join(BASE_PATH, "config", "setting.ini")
api_root_url = data.load_ini(data_file_path)["host"]["api_root_url"]


class Favorite_Dsh(RestClient):

    def __init__(self, api_root_url, **kwargs):
        super(Favorite_Dsh, self).__init__(api_root_url, **kwargs)

    def create(self,**kwargs):
        '''
        创建收藏夹
        '''
        return self.post("/api/favorite_dsh/create", **kwargs)

    def delete(self,**kwargs):
        '''
        删除收藏夹
        '''
        return self.post("/api/favorite_dsh/delete", **kwargs)

    def get_tree_api(self, **kwargs):
        """
        获取当前用户收藏夹树
        """
        return self.get('/api/favorite_dsh/get_tree', **kwargs)

favorite_dsh = Favorite_Dsh(api_root_url)